package edu.spec.teacher.controller;

import edu.spec.sys.model.User;
import edu.spec.sys.model.dto.MvcReturn;
import edu.spec.sys.model.enumeration.Status;
import edu.spec.teacher.model.SignIn;
import edu.spec.teacher.service.iface.ISignInService;
import edu.spec.teacher.service.iface.IUserSignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * Author       : MadFrog
 * Date         : 2018/10/9 19:02
 * Description  :
 */
@Controller
@RequestMapping("/teacher/signIn")
public class SignInController {

    @Autowired
    private ISignInService signInService;
    @Autowired
    private IUserSignInService userSignInService;

    @ResponseBody
    @RequestMapping("/add")
    public Object add(SignIn signIn, HttpSession session){
        signIn.setStatus(Status.ENABLED);
        signIn.setCreateDate(new Date());
        User user = (User)session.getAttribute("user");
        signIn.setCreator(user);
        signInService.add(signIn);
        return new MvcReturn(true, "创建签到成功！");
    }

}
